# study-code
# depth-first search 1
# Sum of Integers
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0030&lang=jp
#
# start 2011/10/10 0:11
# end   2011/10/10 1:25

DATA_INPUT = <<DATA
3 6
3 1
0 0
DATA

def parse_input( str )
    input = []
    pattern = /^\d \d$/
    str.split("\n").each{|data_set|
        unless pattern.match( data_set )
            throw "input match failure: " + data_set
        end
        n,s = data_set.split(" ").map!{|i| i.to_i }
        if(n == 0 && s == 0)
            break
        else
            input.push [n,s]
        end
    }
    return input
end




def solve( data_set )
    n,s = data_set
    result = []
    search(n, s, [], [], result)
    return result
end


def search( n, s, choise, visited,result)
    unless( check_visited( visited, choise ) )
        puts "check : n=#{n} s=#{s} data=#{ choise.inspect }"
        visited.push choise
        if(choise.length == n)
            if( check_goal( n, s, choise ) )
                result.push( choise )
            end
            return
        end

        (0 .. 9).to_a.each{|i|
            list = Array.new( choise )
            unless( list.include?( i ) )
                list.push i
                search( n, s, list, visited, result )
            end
        }
    end
end

def check_visited(visited, choise)
    for v in visited do
        if(v.length == choise.length)
            r = true
            for i in choise do
                unless(v.include?(i))
                    r = false
                end
            end
            return true if r
        end
    end
    return false
end

def check_goal(n,s,choise)
    sum = 0
    choise.each{|i|
        sum += i
    }
    return sum == s
end

set = parse_input DATA_INPUT
p set
set.each{|i|
    p solve( i )
}

